import Axios from 'axios'
import Config from '../../config'

const state = {
  user: null
}

const getters = {}

const actions = {
  //注册
  async register({ commit }, user) {
    const response = await Axios.post(`${Config.url}/user/register`, user)
    if (response.message) {
      console.log('register success')
    }
  },

  //登录
  async login({ commit }, user) {
    const response = await Axios.get(`${Config.url}/user/login`, user)
    if (response.token) {
      console.log(response.token)
    }
  }
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations
}
